package com.cw.jeeyt.service.converter.git;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.git.GitBranchSqlManageBo;
import com.cw.jeeyt.dao.model.git.GitBranchSqlManageDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * git数据库脚本管理转换类
 *
 * @author chenw
 * @date 2019-02-25 01:04:34
 */
public class GitBranchSqlManageConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static GitBranchSqlManageBo do2Bo(GitBranchSqlManageDo model) {
        if (model == null) {
            return null;
        }
        GitBranchSqlManageBo bo = new GitBranchSqlManageBo();
        bo.setId(model.getId());
        bo.setBranchId(model.getBranchId());
        bo.setSqlCode(model.getSqlCode());
        bo.setSqlDesc(model.getSqlDesc());
        bo.setSqlType(model.getSqlType());
        bo.setUploadPath(model.getUploadPath());
        bo.setUploadUserId(model.getUploadUserId());
        bo.setUploadUserName(model.getUploadUserName());
        bo.setCreateBy(model.getCreateBy());
        bo.setCreateDate(model.getCreateDate());
        bo.setUpdateBy(model.getUpdateBy());
        bo.setUpdateDate(model.getUpdateDate());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static GitBranchSqlManageDo bo2Do(GitBranchSqlManageBo bo) {
        if (bo == null) {
            return null;
        }
        GitBranchSqlManageDo model = new GitBranchSqlManageDo();
        model.setId(bo.getId());
        model.setBranchId(bo.getBranchId());
        model.setSqlCode(bo.getSqlCode());
        model.setSqlDesc(bo.getSqlDesc());
        model.setSqlType(bo.getSqlType());
        model.setUploadPath(bo.getUploadPath());
        model.setUploadUserId(bo.getUploadUserId());
        model.setUploadUserName(bo.getUploadUserName());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<GitBranchSqlManageBo> doList2BoList(List<GitBranchSqlManageDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), GitBranchSqlManageConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<GitBranchSqlManageDo> boList2DoList(List<GitBranchSqlManageBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), GitBranchSqlManageConverter::bo2Do));
    }
}